ABC162 D - RGB Triplets
解答
code: python
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
for j in range(i + 1, n):
k = (j-i) + j
if (k < n) and ({si, sj, sk} == {'R', 'G', 'B'}): ans -= 1
print(ans)
メモ
提出
code: python
import itertools
n = int(input())
s = input()
# 等間隔ではない
# 2つ決めたら自動的に3つ目が決まる
# 計算量
# for i in itertools.combinations(range(4000), 2):
# print(i)
r = []
g = []
b = []
for i in range(len(s)):
r.append(i)
print(i)
g.append(i)
b.append(i)
setr = set(r)
setg = set(g)
setb = set(b)
print(r, g, b)
# どうやって等間隔, 順番異なるを引くか
print(len(r)*len(g)*len(b))
ans = len(r)*len(g)*len(b)
# R, G, Bの順番ってわけではない
# for i in r:
# for j in g:
# for k in b: